Coding Pattern:
Intervals
This pattern has an earnable cheat sheet.
Pattern concept
Step 1 of 12
Use ← → arrow keys
Code snippets
How to identify
Does the problem involve any of these?
- Finding overlapping intervals
- Meeting Rooms I: Find whether there are overlapping intervals.
- Interval List Intersections: Find the intersection of intervals.
- Rearranging or updating a list of intervals, or creating a schedule that fits a condition
- Insert Interval Insert a new interval into a sorted list of intervals.
- Merge Intervals: Merge all overlapping intervals.
Note
Most interval problems can be solved in O(n) time since usually each element in the interval list needs to be iterated over once.